package com.wfh.manager;

import lombok.Data;
import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.client.RedisClient;
import org.redisson.config.Config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


/**
 * @Author FengHuan Wang
 * @Date 2025/4/18 20:15
 * @Version 1.0
 */
@Configuration
@ConfigurationProperties(prefix = "spring.data.redis")
@Data
public class RedisManager {

    private String port;

    private String host;

    private String password;

    private int database;


    @Bean
    public RedissonClient redisClient(){
        final String REDIS_URL = "redis://" + host + ":" + port;
        Config config = new Config();
        config.useSingleServer().setAddress(REDIS_URL).setPassword(password).setDatabase(database);
        return Redisson.create(config);
    }
}
